Skip to content

fix: correct managed OAuth credential name lookup for gateway MCP clients#543

Merged
tejaskash merged 2 commits intoaws:mainfrom
aidandaly24:fix/credential-provider-name-mismatch
Mar 13, 2026
Merged

fix: correct managed OAuth credential name lookup for gateway MCP clients#543
tejaskash merged 2 commits intoaws:mainfrom
aidandaly24:fix/credential-provider-name-mismatch

Conversation

@aidandaly24
Copy link
Contributor

@aidandaly24 aidandaly24 commented Mar 13, 2026

Description

Fixed a credential name mismatch that caused agent runtimes to crash when connecting to gateways with CUSTOM_JWT auth.

When a gateway with CUSTOM_JWT auth is created, the CLI creates a managed OAuth credential with the suffix -oauth (e.g. my-gateway-oauth). However, when generating the MCP client code for the agent, schema-mapper.ts looked up the credential using the suffix -agent-oauth (e.g. my-gateway-agent-oauth). This lookup failed silently, resulting in an empty provider_name in the generated @requires_access_token decorator.

At runtime, the agent crashed with:

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid length for parameter resourceCredentialProviderName, value: 0, valid min length: 1

The fix aligns the lookup suffix in schema-mapper.ts and the UI preview in AddGatewayScreen.tsx to match the creation suffix (-oauth). Added a regression test to prevent future naming drift.

Related Issue

Closes #544

Documentation PR

N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@aidandaly24 aidandaly24 requested a review from a team March 13, 2026 15:20
@github-actions github-actions bot added the size/xs PR size: XS label Mar 13, 2026
…ents

The managed OAuth credential is created with the suffix '-oauth' (e.g.
'my-gateway-oauth') but was being looked up with '-agent-oauth' in
schema-mapper.ts and displayed with '-agent-oauth' in AddGatewayScreen.

This mismatch caused the credential lookup to fail silently, resulting
in an empty provider_name in the generated @requires_access_token
decorator. The agent runtime then crashed with:
  ParamValidationError: Invalid length for parameter
  resourceCredentialProviderName, value: 0, valid min length: 1
@aidandaly24 aidandaly24 force-pushed the fix/credential-provider-name-mismatch branch from 138cee9 to e6cd895 Compare March 13, 2026 16:03
@github-actions github-actions bot added size/s PR size: S and removed size/xs PR size: XS labels Mar 13, 2026
Replace inline credential name construction with a shared function in
credential-utils.ts. All three consumers (GatewayPrimitive, schema-mapper,
AddGatewayScreen) now use the same function, preventing future naming drift.

Add regression test for the shared function.
@github-actions github-actions bot added size/s PR size: S and removed size/s PR size: S labels Mar 13, 2026
Copy link
Contributor

@tejaskash tejaskash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — clean bug fix, correct root cause, shared utility prevents future drift. Ship it.

@tejaskash tejaskash merged commit 30e6a74 into aws:main Mar 13, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP client.py template generates empty provider name for gateway target with no auth

2 participants